//
//  ProblemHandlingCell.m
//  Utils
//
//  Created by enghou on 2018/4/14.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "ProblemHandlingCell.h"
#import "XIBLabel.h"
@interface ProblemHandlingCell()
@property (weak, nonatomic) IBOutlet UILabel *senderLabel;
@property (weak, nonatomic) IBOutlet UILabel *eventNameLabel;
@property (weak, nonatomic) IBOutlet XIBLabel *stateLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UILabel *typeNameLabel;

@property (weak, nonatomic) IBOutlet UIButton *handleBtn;

@property (weak, nonatomic) IBOutlet UIButton *handleProcess;

@property (weak, nonatomic) IBOutlet UIButton *moreBtn;

@end

@implementation ProblemHandlingCell
- (IBAction)handleAction:(id)sender {
    if (_model.accepted) {
        //
        [[NSNotificationCenter defaultCenter]postNotificationName:@"PreHandleProblem" object:_model];
    }else{
        [[NSNotificationCenter defaultCenter]postNotificationName:@"HandleProblem" object:_model];
    }
}
- (IBAction)processingAction:(id)sender {
    [[NSNotificationCenter defaultCenter]postNotificationName:@"ProcessProblem" object:_model];
}
- (IBAction)moreAction:(id)sender {
    [[NSNotificationCenter defaultCenter]postNotificationName:@"MoreProblem" object:_model];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)setModel:(ProblemHandlingItemModel *)model{
    _model = model;
    self.senderLabel.text = _model.sender;
    self.stateLabel.text = _model.type;
    self.dateLabel.text = _model.time;
    self.eventNameLabel.text = _model.eventName;
    self.contentLabel.text = _model.content;
    self.typeNameLabel.text = _model.typeName;
    if (_model.state == 0) {
        //矛盾纠纷待办
        self.handleBtn.enabled = YES;
        if (_model.accepted) {
            [self.handleBtn setTitle:@"受理" forState:UIControlStateNormal];
        }else{
            [self.handleBtn setTitle:@"办理" forState:UIControlStateNormal];
        }
        self.handleProcess.enabled = YES;
        [self.handleProcess setTitle:@"处理过程" forState:UIControlStateNormal];
        self.moreBtn.enabled = YES;
        [self.moreBtn setTitle:@"更多" forState:UIControlStateNormal];
    }else if (_model.state == 1 || _model.state == 2 || _model.state == 4){
        //矛盾纠纷已办
        self.handleBtn.enabled = NO;
        [self.handleBtn setTitle:@"" forState:UIControlStateNormal];
        self.handleProcess.enabled = YES;
        [self.handleProcess setTitle:@"处理过程" forState:UIControlStateNormal];
        self.moreBtn.enabled = NO;
        [self.moreBtn setTitle:@"" forState:UIControlStateNormal];
    }else if (_model.state == 3){
        self.handleBtn.enabled = NO;
        [self.handleBtn setTitle:@"" forState:UIControlStateNormal];
        self.handleProcess.enabled = YES;
        [self.handleProcess setTitle:@"处理过程" forState:UIControlStateNormal];
        self.moreBtn.enabled = YES;
        [self.moreBtn setTitle:@"更多" forState:UIControlStateNormal];
    }else if (_model.state == 5){
        self.handleBtn.enabled = NO;
        [self.handleBtn setTitle:@"" forState:UIControlStateNormal];
        self.handleProcess.enabled = NO;
        [self.handleProcess setTitle:@"" forState:UIControlStateNormal];
        self.moreBtn.enabled = NO;
        [self.moreBtn setTitle:@"" forState:UIControlStateNormal];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)layoutSubviews{
    
}

@end
